//
//  ZHTabBarController.swift
//  999999新浪微博
//
//  Created by 陈华 on 15/12/15.
//  Copyright © 2015年 华锐. All rights reserved.
//

import UIKit

class ZHTabBarController: UITabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        setValue(ZHCustomTabBar(), forKey: "tabBar")//自定义tabBar
        let navHome = settterController(ZHHomeController(), title: "首页", imageNmae: "tabbar_home")
        let nvaMessage = settterController(ZHMessageController(), title: "消息", imageNmae: "tabbar_message_center")
        let nvaProfile = settterController(ZHProfileController(), title: "我", imageNmae: "tabbar_profile")
        let nvaDiscover =  settterController(ZHDiscoverController(), title: "发现", imageNmae: "tabbar_discover")
        setViewControllers([navHome,nvaMessage,nvaProfile,nvaDiscover], animated:false)
        self.tabBar.tintColor = UIColor.orangeColor()//设置tabBar渲染颜色
        setNavAppeareance()
    }
    //MARK: - 设置控制器
    private func settterController(controller: UIViewController, title: String, imageNmae: String) ->UINavigationController{
        
        let nav = UINavigationController(rootViewController: controller)
        controller.title = title
        controller.tabBarItem.image = UIImage(named: imageNmae)
        controller.tabBarItem.selectedImage = UIImage(named: imageNmae + "_highlighted")//tabBarItem有选中状态
        return nav
    }
    
    ///设置全局的Nav皮肤样式
    func setNavAppeareance(){
        let nav = UINavigationBar.appearance()
        nav.tintColor = UIColor.orangeColor()
    }

    
}
















